package com.aishang.shopback_2005.controller;

import com.aishang.shopback_2005.po.Orderitem;
import com.aishang.shopback_2005.po.Orders;
import com.aishang.shopback_2005.po.OrdersExt;
import com.aishang.shopback_2005.po.Product;
import com.aishang.shopback_2005.service.OrderService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author a1790
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    OrderService orderService;

    /**
     * 获取所有订单
     * @param ordersExt
     * @return
     */
    @RequestMapping("/getAllOrders")
    public PageInfo<Orders> getAllOrders(@RequestBody OrdersExt ordersExt){
        return orderService.getAllOrders(ordersExt);
    }

    /**
     * 查询订单项和商品信息
     * @param oid
     * @return
     */
    @RequestMapping("/getProductByOid")
    public List<Orderitem> getProductByOid(Integer oid){
        return orderService.getProductByOid(oid);
    }

    /**
     * 更新订单信息
     * @param orders
     * @return
     */
    @RequestMapping("/updateOrders")
    public String updateOrders(@RequestBody Orders orders){
        orderService.updateOrders(orders);
        return "ok";
    }
}
